package com.platform.core.security.auth;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * Description: 登录监听
 *
 * @author sunzhubin.zh created on 2019/9/30
 */
@Component
public class LoginSuccessListener {

    @EventListener
    @Async
    public void success(LoginSuccessEvent loginSuccessEvent) {
        Object obj = loginSuccessEvent.getSource();
        if (Objects.nonNull(obj)) {
            loginSuccessEvent.getSysUserService().recordLoginDate(obj.toString());
        }
    }
}
